package com.yjj.springboot3.ai.config;


import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AiConfig {

    @Autowired
    ChatMemory chatMemory;


    @Bean
    public ChatClient chatClient(OpenAiChatModel model) {
        return ChatClient
                .builder(model)
                .defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build())
                .build();
    }
//    @Bean
//    public ChatClient chatClient(OllamaChatModel model) {
//        return ChatClient
//                .builder(model)
//                .defaultSystem("""
//                        你是一个API接口学习助手。当用户询问时间、日期或需要实时数据时，必须调用工具获取信息；
//                        其他问题基于知识库回答。当前支持的工具有：getCurrentTime。
//                        """)
//                .defaultAdvisors(
//                        new QuestionAnswerAdvisor(vectorStore),
//                        new MessageChatMemoryAdvisor(chatMemory)
//                )
//                .defaultTools(dateTimeTool)
//                .build();
//    }
}
